<template>
	<view>
		<uni-popup ref="popup" type="center">
			<view class="model">
				<!-- <view class="text-center paddingtb-20 base-size" style="color: #727375;border-bottom: 1upx solid #727375;">温馨提示</view> -->
				<view class="model-content">
					<view v-if="url == 'close'" class="text-center size-16">提交成功！</view>
					{{title}}
				</view>
				<!-- <view :class=" noCloseBtn ? 'model-btn-noclose' : 'model-btn' " class="text-center"> -->
				<view @click="handleKnow" class="text-center paddingtb-20 size-16" style="color: #727375;">我知道了</view>
				<!-- <text @click="handleOk" class="model-btn-confirm">{{okText || "我知道了"}}</text> -->
			</view>
		</uni-popup>
	</view>
</template>

<script>
	import uniPopup from "@/components/uni-popup/uni-popup.vue"
	/**
	 * 提示消息组件
	 * @property {String} title 提示的消息
	 * @property {Function<Promise>} okFun 确认需要处理的方法
	 * @property {Boolern} noCloseBtn 是否需要取消按钮
	 * @example <prompt ref="prompt" :title="'您是否确定要退出小程序且解除微信绑定'" :okFun="handleOk"></prompt>
	 * 		handleOk() {
			   return new Promise((res,rej) => {
				   res("ok")
			   })
			}
	 */
	export default {
		data() {
			return {
				
			};
		},
		components:{
			uniPopup
		},
		methods:{
			open() {
				this.$refs.popup.open();
			},
			close() {
				this.$refs.popup.close();
			},
			async handleOk() {
				if(this.okFun) {
					await this.okFun()
				}
				this.close();
			},
			handleKnow() {
				// if(this.url == 'no'){ // 关闭蒙版，不做任何跳转
				// 	this.close();
				// } else 
				if(this.url == 'back'){ // 关闭蒙版，返回上一页
					uni.navigateBack()
				} else if(this.url == 'close'){ // 关闭页面，返回公众号首页
					this.close();
					WeixinJSBridge.call('closeWindow');
					return
				}else if(this.url.indexOf('http://')==0||this.url.indexOf('https://')==0){
					window.location.href=this.url;
				} else { // 关闭蒙版，返回指定页
					uni.redirectTo({
						url:this.url
					})
				}
				this.close();
				// if(this.cancelFun) {
				// 	await this.cancelFun()
				// }
				// this.close();
			}
		},
		props:["okFun","title","noCloseBtn","url","okText","cancelText"]
	}
</script>

<style scoped lang="scss">
 .model{
	 background: #fff;
	 width: 580upx;
	 border-radius: 8upx;
 }
 .model-content{
	 padding: 48upx 80upx;
	 font-size: 32upx;
	 line-height: 48upx;
	 text-align: center;
	 color: #727375;
	 border-bottom: 1px solid #727375;
 }
 .model-btn-noclose{
	 line-height: 96upx;
	 border-top: 1px solid #F5F5F5;
	 text-align: center;
	 font-size: 32upx;
	 color: #25262A;
 }
 .model-btn{
	 line-height: 96upx;
	 border-top: 1px solid #F5F5F5;
	 text{
		 display: inline-block;
		 width: calc(50% - 1px);
		 text-align: center;
		 color: #727375;
		 font-size: 32upx;
	 }
	 .model-btn-confirm{
		 border-left:1px solid #F5F5F5 ;
		 color: #25262A;
	 }
 }
</style>
